<template>
  <div>
    <div>这里是第2个页面</div>
    <div class="hello">myName : {{myName}}</div>
    <div class="hello" @click="setName">设置name</div>
  </div>
</template>

<script>
import { mapState } from '../vuex/index';
// import { mapState } from 'vuex';
export default {
	name: 'HelloWorld',
	data() {
		return {
			name: 'init',
			// myName: '',
		};
	},
	methods: {
		setName() {
			// this.$store.commit('changeName', Date.now());
			this.$store.state.name = Date.now() + '222';
			console.log(Date.now());
		},
	},
	mounted() {
		// this.myName = this.$store.state.name;
	},
	computed: {
		myName: {
			get() {
				return this.$store.getters.getName;
			},
		},
	},
	// computed: {
	// 	...mapState({
	// 		myName: ({ user }) => user.name,
	// 	}),
	// },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
	font-weight: normal;
}
ul {
	list-style-type: none;
	padding: 0;
}
li {
	display: inline-block;
	margin: 0 10px;
}
a {
	color: #42b983;
}
</style>
